import pygame
import sys
from game_function import *
from settings import settings
from ship import Ship
from pygame.sprite import Group
from alien import Alien

def run_game():
    pygame.init()# 背景初始化

    ai_settings = settings()# 设置初始值屏幕

    screen = pygame.display.set_mode((ai_settings.screen_length, ai_settings.screen_width))
    pygame.display.set_caption("elien invasion")

    ship = Ship(screen, ai_settings)
    bullets = Group()

    aliens = Group()
    create_fleet(ai_settings, screen, aliens, ship)
    # 游戏的主循环
    while True:

        check_events(ai_settings, screen, ship, bullets)
        ship.update()
        # 每次循环都重绘制屏幕
        update_bullets(bullets)
        update_aliens(ai_settings, aliens)
        print(len(aliens))
        update_screen(ai_settings, screen, ship, bullets, aliens)


